package com.peng.rpc.api;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Wonderson
 * @email wpp.ds@foxmail.com
 * @date 2022/3/7 19:02
 */
@Data
public class LoverArg implements Serializable {

    private final Map<String, Lover> lovers = new ConcurrentHashMap<>();

    public LoverArg() {
    }

    public LoverArg addLover(String role, String name, int age) {
        lovers.put(role, new Lover(name, age));
        return this;
    }

    public Lover getLover(String role) {
        return lovers.get(role);
    }

    @Override
    public String toString() {
        return lovers.toString();
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor //HelpReflection
   public static class Lover implements Serializable {
        private String name;
        private int age;
    }
}
